/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package program.gui.model;

import java.util.ArrayList;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;
import program.beans.Category;

/**
 * Model for category-combobox
 * 
 * Responsible: Patrick
 */
public class CategoryComboBoxModel extends AbstractListModel implements ComboBoxModel{
    
    private ArrayList<Category> categories;
    private String c;

    public CategoryComboBoxModel(ArrayList<Category> categories) {
        this.categories = categories;
    }

    @Override
    public int getSize() {
        return categories.size();
    }

    @Override
    public Object getElementAt(int index) {
        return categories.get(index).getDescription();
    }

    @Override
    public void setSelectedItem(Object anItem) {
        c = (String) anItem;
    }

    @Override
    public Object getSelectedItem() {
        return c;
    }
    
    
}
